#!/bin/bash

#------------------Create Data------------------
echo "
#par degree             Nehalem     SandyBridge     Baseline CUDA           OptimisedCUDA           Edgecon Split       Vflux Split
2                       241235.794  357002.3193     255960.6033             -                       -                   110255.64489
4                       139585.289  166955.2403     255960.6033             -                       -                   110255.64489
6                       114829.428  -               255960.6033             -                       -                   110255.64489
8                       85227.8648  -               255960.6033             -                       -                   110255.64489
12                      79401.9890  -               255960.6033             -                       -                   110255.64489
"> data1


#--------------------------Plot Data----------------------------

gnuplot <<END

set term epslatex color
set grid xtics ytics mxtics mytics    
set size 1,0.85
#set format "$%g$"


#set format xy "2^{%b}"
set format xy "$%g$"

set xlabel "Number of cores (1 MPI process per core)" 
set ylabel "Execution time (milliseconds)" 3,1

set datafile missing '-'

#set xrange [50:21000]
set yrange [0:500000]

set style line 1 lt -1 lw 0.3
set key width 0
set key box linestyle 1 right top


#set log x 2
#set log y 2
set border lw 2

set output "./Fig.tex"

plot "data1" u 1:2 with linespoints title "MPI (westmere)"      lt 1 pt 8  linecolor rgb '#880000' lw 3 ps 1.5, \
"data1" u 1:3 with linespoints title "MPI (sandy bridge)"      lt 1 pt 7  linecolor rgb '#7CFC00' lw 3 ps 1.5, \
"data1" u 1:4 with lines title "CUDA-Baseline"      lt 2  linecolor rgb '#0000CC' lw 6, \
"data1" u 1:7 with lines title "CUDA-Optimised"      lt 1  linecolor rgb '#0000AA' lw 6;


END



epstopdf Fig.eps

#-----------------------------------------
echo " \documentclass{article}
\usepackage{graphics}
\usepackage{nopageno}
%\usepackage{mathpazo}
\usepackage{txfonts}
\usepackage[usenames]{color}
	
\begin{document}
	
\begin{center}
  \small{
  \input{./Fig.tex}}
\end{center}
	
\end{document}" > Figure.tex
#-----------------------------------------

pdflatex Figure.tex
pdfcrop Figure.pdf

mv Figure-crop.pdf Scalability_N4.pdf

rm -f data* Figure.tex Figure.pdf Figure.log Figure.aux Figure.log Fig.eps Fig.tex Fig.pdf *~
evince Scalability_N4.pdf &
